<?php


namespace App\Transformers\User;


use App\Models\LableCategory;
use League\Fractal\TransformerAbstract;

class LableCategoriesTransformer extends TransformerAbstract
{

    public $availableIncludes = ['lable'];

    public function transform(LableCategory $lableCategory)
    {
        return [
            'id'=>$lableCategory->id,
            'pid'=>$lableCategory->pid ?? '',
            'system_admin_id'=>$lableCategory->system_admin_id ?? '',
            'name'=>$lableCategory->name ?? '',
            'sort'=>$lableCategory->sort ?? 0,
            'type'=>$lableCategory->type ?? 0,
            'created_at' => $lableCategory->created_at ? $lableCategory->created_at->format("Y-m-d H:i:s") : '',
            'updated_at' => $lableCategory->updated_at ? $lableCategory->updated_at->format("Y-m-d H:i:s") : '',
        ];
    }

    public function includelable(LableCategory $lableCategory)
    {
       return $this->collection($lableCategory->userLabel,new UserLabelsTransformer());
    }
}
